home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Environments / Prograph Classic 2.6.1 / Prograph Reference Manual / Prograph Reference 1-4 / Prograph Reference 1-4.rsrc / TEXT_137.txt < prev    next >
Encoding:
Text File  |  1995-10-21  |  5.2 KB  |  125 lines

  1.  
  2. t    Controls*19*
  3.  
  4. Flow of execution within a Prograph program is effected by Controls attached to operations. A control is activated on either success or failure of its operation. Prograph operations can succeed, fail, or be in error.
  5.  
  6.  Success, Failure, and Error*20*
  7.  
  8. Success*20*
  9.  
  10. The default result for execution of an operation is success.
  11.  
  12. Failure*20*
  13.  
  14. An operation fails if:
  15.  
  16. o it is a match operation and the comparison it makes fails,
  17.  
  18. o it is a Boolean operation with no roots that evaluates to FALSE (Note: a Boolean operation can have no root or one root. If it has one root, it either returns TRUE or FALSE. If it has no root, it either succeeds or fails.),
  19.  
  20. o failure is propagated to it by an operation with a Fail control (see the ‚ÄúFail‚Äù section below in this chapter). 
  21.  
  22. Error*20*
  23.  
  24. An operation generates an error if:
  25.  
  26. o it is a primitive with inputs of inappropriate type or value,
  27.  
  28. o it fails and does not have a control that fires on failure,
  29.  
  30. o it has a Next Case control and the case in which the operation resides is the last case of the method,
  31.  
  32. o the method called cannot be found,
  33.  
  34. o the method found has arity different from that of the calling operation.
  35.  
  36. NOTE: If an error occurs, the interpreter beeps twice and the user is brought back to Editor context, with a case window open onto the offending operation, which is highlighted and blinking. An error message is also available.*20*
  37.  
  38.  The Controls*20*
  39.  
  40. Prograph displays controls as small square icons attached to the right of operation icons. A control has two aspects: the action to be taken, and whether this action is taken on success or failure of the operation. Control icons depict these two aspects as follows:
  41.  
  42. o A check mark (‚àö) within the control icon indicates that it is activated on success of the operation*21*
  43.  
  44. o An X within the control icon indicates that it is activated on failure of the operation (Note: We refer to either the ‚àö or the X as an activation mark.)
  45.  
  46. o The other graphics within the square icon indicate the action to be taken.
  47. The controls and their actions are as follows.
  48.  
  49. Next Case*21*
  50.  
  51.  
  52.  
  53.  Abandon processing of the current case, and go on to execute the next case in the method. If there is no next case, signal an error.    
  54.  
  55. The Next Case icon is plain, with nothing inside it except for its activation mark.
  56.  
  57. Continue*21*
  58.  
  59.  
  60.  
  61.  Continue execution of the current case. Continue on Success is the default for operations, and has no icon.    
  62.  
  63. Continue on Failure has an X activation mark and miniature input and output bars within the control icon.
  64.  
  65. Terminate*21*
  66.  
  67.  
  68.  
  69.  Terminate execution of the current case immediately, and halt any repetition of the current method. If any values are output, these are the values computed on the last successful iteration of the method, or NULL if there was no iteration.    
  70.  
  71. The Terminate control has a miniature input bar within its icon, to suggest that the values returned are those on the input bar (that is, those returned on the output bar on the last successful iteration). 
  72.  
  73. Finish*21*
  74.  
  75.  
  76.  
  77.  Finish execution of the current case (that is, continue execution of the current case), and halt any repetition of the current method. The values output (if any) are those computed by the current case.    
  78.  
  79. The Finish control has a miniature output bar within its icon.
  80.  
  81. Fail*22*
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  Propagate failure to the calling operation. 
  92.  
  93. At left, the write-line primitive returns 0 if no error occurs. The match-with-0 operation has a Fail on Failure control, so if write-line doesn‚Äôt return 0 , the match fails, and Failure is propagated to the write out operation, which in turn fails. There should be an appropriate control on the write out operation to handle that failure.  
  94.  
  95.  Inject*22*
  96. ¬† 
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  An Inject terminal supplies a name to an operation at runtime. A string flowing into the operation through the inject terminal becomes the operation‚Äôs name.
  105.  
  106. Inject is applied to a selected terminal by means of the Inject menu item in the Controls menu. The terminal assumes a distinctive shape. Inject can be combined with List and Loop annotations.    
  107.  
  108. In the example above, an instance is expected as input to the method. The attributes primitive returns, on its right root, a list of the names of the instance attributes of that instance. This list flows into the right terminal, annotated with both List and Inject, of the Get operation. The Get operation applies itself to every element of the incoming list, getting the value of the attribute named by that string element, and produces a list of attribute values on its list-annotated right root. *22*
  109.  
  110. t Persistents*23*
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  Persistents are named elements that can hold any value. This value is retained between executions of a program and is also saved by the Prograph editor along with its program.
  120.  
  121. A Persistent is created by cmd-clicking space in the Persistents window. Its name is typed below its icon, and its value can be set at edit time by double-clicking its icon, which opens a Value window.    *23*
  122.  
  123. __________________________________________________________
  124. NOTE: When running in compiled mode, values of persistents can be saved and restored using the save and load primitives.
  125. ----------------------------------------------------------